package parser;


/**
 * Token class
 * @author Dave en Timo
 *
 */
public class Token {
	private final TokenKind tokenKind;
	private final String text;
	private final int line;
	private final int column;

	public Token(TokenKind kind, String text, int line, int column) {
		this.tokenKind = kind;
		this.text = text;
		this.line = line;
		this.column = column;
	}

	public TokenKind getTokenKind() {
		return tokenKind;
	}

	public String getText() {
		return text;
	}

	public int getLine() {
		return line;
	}

	public int getColumn() {
		return column;
	}

	public String toString() {
		return String.format("TokenKind: %s \nText: %s\n================", tokenKind, text);
	}
	
	public int hashCode() {
		return text.hashCode();
	}

	/**
	 * Token comparisation param: Object
	 */
	public boolean equals(Object object) {
		boolean equals = false;

		if (object instanceof Token) {
			Token token = (Token) object;

			equals = token.getText().equals(text);
		}

		return equals;
	}
}